package cn.worldyao.demo.entity;


import cn.worldyao.demo.config.LocalDateTimeConfig;
import cn.worldyao.demo.util.Tools;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 *
 * </p>
 *
 * @author yaozi
 * @since 2020-03-11
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class SysPermission extends Model<SysPermission> {

    private static final long serialVersionUID = 1L;

    @TableId(value = "PID", type = IdType.INPUT)
    private String pid;

    @TableField("NAME")
    private String name;

    @TableField("DESCRIPTION")
    private String description;

    @TableField("URL")
    private String url;

    @TableField("CREATE_TIME")
    @JsonDeserialize(using = LocalDateTimeConfig.class)
    private LocalDateTime createTime;

    @TableField("UPDATE_TIME")
    @JsonDeserialize(using = LocalDateTimeConfig.class)
    private LocalDateTime updateTime;


    @Override
    protected Serializable pkVal() {
        return this.pid;
    }

    public void Init() {
        this.setPid(Tools.UUID8());
        this.setCreateTime(LocalDateTime.now());
        this.setUpdateTime(LocalDateTime.now());
    }

}
